
include(${CMAKE_CURRENT_LIST_DIR}/App4ConfigureLauncherTestStepPrerequisites.cmake)

set(CMAKE_CONFIGURATION_TYPES "@CMAKE_CONFIGURATION_TYPES@")
set(CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@")
set(CMAKE_EXECUTABLE_SUFFIX "@CMAKE_EXECUTABLE_SUFFIX@")

set(TEST_TREE_TYPE "@TEST_TREE_TYPE@")

# --------------------------------------------------------------------------
# Attempt to guess launcher build type

set(ctkapplauncher_name CTKAppLauncher${CMAKE_EXECUTABLE_SUFFIX})
set(ctkapplauncher_dir "@LAUNCHER_DIR@")
if(CMAKE_CONFIGURATION_TYPES AND TEST_TREE_TYPE STREQUAL "BuildTree")
  foreach (type ${CMAKE_CONFIGURATION_TYPES})
    set(name ${type}/CTKAppLauncher${CMAKE_EXECUTABLE_SUFFIX})
    if(EXISTS ${ctkapplauncher_dir}/bin/${name})
      set(ctkapplauncher_name ${name})
    endif()
  endforeach()
endif()

# --------------------------------------------------------------------------
# Set launcher variable

set(launcher_build_subdir ".")
if(CMAKE_CONFIGURATION_TYPES)
  set(launcher_build_subdir "@APP4CONFIGURELAUNCHERTEST_BUILD_TYPE@")
  if(TEST_FUNCTION STREQUAL "ForExecutable")
    set(launcher_build_subdir ".")
  endif()
endif()
set(launcher_exe ${app4configurelaunchertest_binary_dir}/App4ConfigureLauncherTest${CMAKE_EXECUTABLE_SUFFIX})

# --------------------------------------------------------------------------
# Sanity checks

if(NOT EXISTS ${app4configurelaunchertest_binary_dir})
  message(FATAL_ERROR "Make sure variable APP4CONFIGURELAUNCHERTEST_BINARY_DIR is set to a valid directory. "
                      "APP4CONFIGURELAUNCHERTEST_BINARY_DIR [${app4configurelaunchertest_binary_dir}]")
endif()
